import request from '../network/request.js'
const confessionWallModule = {
	namespaced: true,

	state: {
		confessionWallInfoList: [],
		publisherInfo: {}
	},

	actions: {
		// 上传墙信息
		addConfessionWallInfo(miniStore, config) {
			request({
				url: '/addConfessionWall',
				method: 'post',
				data: config.confessionWallInfo,
				header: {
					"Authorization": "Bearer " + config.token,
				},
			}).then(data => {
				if (data.status >= 200 && data.status < 300) {
					uni.navigateBack(1)
					return
				}
			}).catch(err => {
				console.log(err)
			})
		},

		// 分页获取墙信息列表
		getConfessionWallInfoList(miniStore, config) {
			request({
				url: '/getConfessionWallInfoList',
				method: 'get',
				header: {
					"Authorization": "Bearer " + config.token,
				},
			}).then(data => {
				miniStore.state.confessionWallInfoList = data.confessionWallInfoList
			}).catch(err => {
				console.log(err)
			})
		},

		// getUploaderInfo
		getPublisherInfo(miniStore, config){
			request({
				url: '/getPublisherInfo?uId=' + config.uId + "&selectContactInfoFlag=" + config.selectContactInfoFlag,
				method: 'get',
				header: {
					"Authorization": "Bearer " + config.token,
				}
			}).then(data => {
				miniStore.state.publisherInfo = data.publisherInfo
			}).catch(err => {
				console.log(err)
			})
		}
	},

	mutations: {

	},

	getter: {

	}

}

export default confessionWallModule